<load href="./Public/js/swfupload.js"/>

<div class="panel-body">
    <form id="myform" name="myform" class="form-horizontal" action="{:U('category/update')}&iscreatehtml=1" method="post">
    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" role="tab" data-toggle="tab">基本设置</a></li>
        <li role="presentation"><a href="#profile" role="tab" data-toggle="tab">SEO设置</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="home">
        <if condition="$Think.const.environment == 'production'">

            <input type="hidden" name="moduleid" value="{$vo['moduleid']}"/>

            <div class="form-group">
                <label class="control-label col-md-2">上级栏目</label>
                <div class="col-md-8">
                    <div class="selectstyle">
                    <select name="parentid" class="form-control" disabled>
                    <option value="">{:L('select_parentid')}</option>
                    {$select_categorys}
                    </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">栏目名称</label>
                <div class="col-md-8">
                    <input type="text" name="catname" class="form-control required" value="{$vo['catname']}"  minlength="1" />
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">页面命名</label>
                <div class="col-md-8">
                    <input type="text" id="catdir" name="catdir" class="form-control  required" value="{$vo['catdir']}" />
                </div>
            </div>
            <div class="form-group" id="module_url" style="display:none;">
                <label class="control-label col-md-2">{:L('cat_link_url')}</label>
                <div class="col-md-8">
                    <input type="text" name="url" class="form-control" value="<if condition="$vo['type']==1">{$vo['url']}</if>" />
                    <input type="hidden" id="type" name="type" value="0" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">栏目图片</label>
                <div class="col-md-8box_thumb">
                    <div class="thumb_image">
                        <div id="image_aid_box"></div>
                        <a href="javascript:;">
                        <img id="image_pic" src="<if condition="!empty($vo['image'])">{$vo['image']}<else/>__PUBLIC__/images/admin_upload_thumb.png</if>" width="60" ></a>
                        <input type="button" value="{:L('clean_thumb')}" onclick="javascript:clean_thumb('image');" class="btn btn-xs btn-primary"/>
                        <input type="hidden" id="image" name="image" value="{$vo['image']}"/>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">导航</label>
                <div class="col-md-8">
                {:Form::radio(array('field'=>'ismenu','options'=>array('1'=>L('yes'),'0'=>L('no'))),$vo['ismenu'])}
                </div>
            </div>
            <input type="hidden" name="ishtml" value="{$vo['ishtml']}">

            <div class="form-group" id="urlrule">
                <label class="control-label col-md-2">{:L('urlrule')}</label>
                <div class="col-md-8">{:Form::select(array('field'=>'urlruleid','options'=>$Urlrule,'options_key'=>'key,listexample'),$vo['urlruleid'])}</div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">分页条数</label>
                <div class="col-md-8">
                <input type="text" name="pagesize" class="form-control w-100" value="<if condition="!empty($vo['pagesize'])">{$vo['pagesize']}</if>" size="3" /> <font color="red">{:L('pagesize_desc')}</font>
                </div>
            </div>

            <else/>
            <div class="form-group">
                <label class="control-label col-md-2">选择类型</label>
                <div class="col-md-8 box_thumb">
                    <div class="selectstyle">
                    {:Form::select(array('field'=>'moduleid','options'=>$module+array('0'=>array('id'=>0,'title'=>L('Module_url'))),'options_key'=>'id,title','setup'=>array('onchange'=>'changetemplate(this.value)')),$vo['moduleid'])}
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">{:L('chose_parentid')}</label>
                <div class="col-md-8">
                    <div class="selectstyle">
                    <select name="parentid" class="form-control">
                    <option value="">{:L('select_parentid')}</option>
                    {$select_categorys}
                    </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">{:L('catname')}</label>
                <div class="col-md-8"><input type="text" name="catname" class="form-control required" value="{$vo['catname']}"  minlength="1" /></div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">页面命名</label>
                <div class="col-md-8"><input type="text" id="catdir" name="catdir" class="form-control  required" value="{$vo['catdir']}" /></div>
            </div>
            <div class="form-group" id="module_url" style="display:none;">
                <label class="control-label col-md-2">{:L('cat_link_url')}</label>
                <div class="col-md-8">
                    <input type="text" name="url" class="form-control" value="<if condition="$vo['type']==1">{$vo['url']}</if>" />
                    <input type="hidden" id="type" name="type" value="0" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">栏目图片</label>
                <div class="col-md-8box_thumb">
                    <div class="thumb_image">
                        <div id="image_aid_box"></div>
                        <a href="javascript:;">
                        <img id="image_pic" src="<if condition="!empty($vo['image'])">{$vo['image']}<else/>__PUBLIC__/images/admin_upload_thumb.png</if>" width="60" ></a>
                        <input type="button" value="{:L('clean_thumb')}" onclick="javascript:clean_thumb('image');" class="btn btn-xs btn-primary"/>
                        <input type="hidden" id="image" name="image" value="{$vo['image']}"/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">{:L('chage_is')}: </label>
                <div class="col-md-8"><div class="selectstyle"><input type="checkbox"  class="input_checkbox "  id="chage_all" name="chage_all" value="1" /><font color="red"> {:L('chage_all')}</font></div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">导航</label>
                <div class="col-md-8">
                {:Form::radio(array('field'=>'ismenu','options'=>array('1'=>L('yes'),'0'=>L('no'))),$vo['ismenu'])}
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">{:L('ishtml')}</label>
                <div class="col-md-8">{:Form::radio(array('field'=>'ishtml','options'=>array('1'=>L('yes'),'0'=>L('no')),'setup'=>array('onclick'=>'urlrule(this.value)')),$vo['ishtml'])}</div>
            </div>

            <div class="form-group" id="urlrule">
                <label class="control-label col-md-2">{:L('urlrule')}</label>
                <div class="col-md-8">{:Form::select(array('field'=>'urlruleid','options'=>$Urlrule,'options_key'=>'key,listexample'),$vo['urlruleid'])}</div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">分页条数</label>
                <div class="col-md-8">
                <input type="text" name="pagesize" class="form-control w-100" value="<if condition="!empty($vo['pagesize'])">{$vo['pagesize']}</if>" size="3" /> <font color="red">{:L('pagesize_desc')}</font>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">列表页模板</label>
                <div class="col-md-8">
                    <select id="template_list" name="template_list" class="form-control w-300 pull-left"></select>
                    &nbsp;&nbsp;
                    <input type="checkbox" class="input_checkbox pull-left" id="listtype" name="listtype"  onclick="javascript:templatetype();" value="1"  <if condition="!empty($vo['listtype'])">checked</if> /> {:L('listtype')}
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">内容页模板</label>
                <div class="col-md-8">
                    <div class="selectstyle">
                    <select id="template_show" name="template_show" class="form-control w-300"></select>
                    </div>
                </div>
            </div>
            </if>
        </div>

        <div role="tabpanel" class="tab-pane" id="profile">

            <div class="form-group">
                <label class="control-label col-md-2">{:L('seo_title')}</label>
                <div class="col-md-8">
                    <input name='title' type='text' id='meta_title' value="{$vo['title']}" class="form-control"  size='60' maxlength='150'>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">{:L('seo_keywords')}</label>
                <div class="col-md-8">
                    <input name='keywords' type='text' id='meta_keywords' value="{$vo['keywords']}" class="form-control"  size='60' maxlength='150'>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-2">{:L('seo_description')}</label>
                <div class="col-md-8">
                    <textarea name='description' id='meta_description' rows="5" cols="60" class="form-control">{$vo['description']}</textarea>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-8">
                <input type="hidden" name="id" value="{$vo.id}">
                <input type="submit" value="提交" class="btn btn-sm btn-primary" >
                <input type="reset" value="取消" class="btn btn-sm btn-primary">
            </div>
        </div>
    </form>

</div>
<script type="text/javascript">
$(document).ready(function() {
    $('#myform').ajaxForm({
        success:  complete,  // post-submit callback
        dataType: 'json'
    });
});

function complete(data){
    if(data.status==1){
        $.scojs_message('修改成功', $.scojs_message.TYPE_OK);
        setTimeout(function(){
            window.location.href = '{:U("Category/index")}';
        },1000);
    }else{
        $.scojs_message(data.info, $.scojs_message.TYPE_ERROR);
    }

}
</script>
<script>
$('.thumb_image a').click(function(){
    swfupload('image_uploadfile','image','{:L(uploadfiles)}',1,1,0,1,'jpeg,jpg,png,gif',3,0,'{$yzh_auth}',yesdo,nodo);
});


var modulearr = new Array();

<volist name="module" id="mdate">
modulearr[{$mdate['id']}] = "{$mdate['name']}";
</volist>

var templatearr = new Array();

<volist name="templates" id="tem">
templatearr[{$i}] = "{$tem['name']},{$tem['value']},{$tem['filename']}";
</volist>


var datas = "<option value=''>{:L('please_chose')}</option>";
var moduleid = $('#moduleid').val();


showtemplist(moduleid,<if condition="empty($vo[listtype])">0<else />{$vo.listtype}</if>);

function showtemplist(m,t){

    var type='_list';

    if(t){
        type='_index';
    }

    var mtlist = modulearr[m]+type;
    var mtshow = modulearr[m]+'_show';

    if(modulearr[m]=='Page')
        mtlist=mtshow ='Page_';

    $('#template_list').html(datas);
    $('#template_show').html(datas);

    listdatas = showdatas ='';

    for(i=1;i<templatearr.length;i++){
        data = templatearr[i].split(',');

        if(data[0].indexOf(mtlist)  >= 0){
            listdatas  ="<option value='"+data[1]+"'>"+data[2]+"</option>";
            $('#template_list').append(listdatas);
        }

        if(data[0].indexOf(mtshow)  >= 0){
            showdatas ="<option value='"+data[1]+"'>"+data[2]+"</option>";
            $('#template_show').append(showdatas);
        }
    }
    $('#template_list').val('{$vo.template_list}');
    $('#template_show').val('{$vo.template_show}');
}

function changetemplate(m){
    if(m==0){
        $('#module_url').show();
        $('#type').val('1');
        $('#catdir').removeClass('required');
    }else{
        $('#module_url').hide();
        $('#type').val('0');
        $('#catdir').addClass('required');
    }
    showtemplist(m,0);
    $("#listtype").removeAttr("checked");
}

function templatetype(){

    var moduleid = $('#moduleid').val();

    if($("#listtype").attr('checked')=='checked'){
        showtemplist(moduleid,1);
    }else{
        showtemplist(moduleid,0);
    }

}

function urlrule(m){
    if(m==1){
        $('#urlrule').show();
    }else{
        $('#urlrule').hide();
    }
}

urlrule({$vo['ishtml']});

<if condition="!empty($_GET['type'])">
    $('#moduleid').val(0);
    changetemplate(0);
</if>
</script>